package com.tourlaid.mamagerment.action.pc

import com.tourlaid.mamagerment.ao.pc.StockInAo
import com.tourlaid.mamagerment.entity.ResponseData
import com.tourlaid.mamagerment.form.StockInForm
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import javax.annotation.Resource

/**
 * Created by xiaoyongge on 2017/7/23.
 * 入库单
 */
@RestController
@RequestMapping("/tld/admin/stockin")
class StockInAction {

    @Resource
    var stockInAo: StockInAo? = null

    @RequestMapping("/list.json")
    fun list(@RequestParam(defaultValue = "1") pageNo: Int,
             @RequestParam(defaultValue = "10") pageSize: Int,
             callback: String): String {
        val ResponseData = stockInAo!!.list(pageNo, pageSize);
        return ResponseData.toJson(callback)
    }

    @RequestMapping("/insert.json")
    fun insert(goodsId: Long?, supplierId: Long?, controlNo: String?, stock: Int?, callback: String): String {
        stockInAo!!.insert(goodsId, supplierId, controlNo, stock);
        return ResponseData<String>().toJson(callback)
    }

    @RequestMapping("/detail.json")
    fun detail(stockInId: Long, callback: String): String {
        var stockInVo = stockInAo!!.detail(stockInId);
        return ResponseData(stockInVo).toJson(callback)
    }

    @RequestMapping("/update.json")
    fun update(form: StockInForm, callback: String): String {
        stockInAo!!.update(form);
        return ResponseData<String>().toJson(callback)
    }

    @RequestMapping("/delete.json")
    fun delete(stockInId: Long?, callback: String): String {
        stockInAo!!.delete(stockInId);
        return ResponseData<String>().toJson(callback)
    }

    @RequestMapping("/getStock.json")
    fun getStock(stockInId: Long, callback: String): String {
        var stock = stockInAo!!.getStock(stockInId);
        return ResponseData(stock).toJson(callback)
    }

}